package river_city_ransom.implementations;

import exceptions.ComposantError;
import river_city_ransom.services.Position;


public class Position_I implements Position {
	private int x;
	private int y;
	private int z;

	public Position_I(int x, int y, int z) {
		super();
		try {
			init(x, y, z);
		}
		catch(ComposantError e) {
			System.err.println(e.getMessage());
		}
	}

	@Override
	public boolean equals(Object o) {
		if(!(o instanceof Position)) {
			return false;
		}
		if(x() != ((Position) o).x()) {
			return false;
		}
		if(y() != ((Position) o).y()) {
			return false;
		}
		if(z() != ((Position) o).z()) {
			return false;
		}

		return true;
	}
	
	@Override
	public String toString() {
		return "[" + x() + " ; " + y() + " ; " + z() + "]";
	}

	/** ________________________________________________________ CONSTRUCTORS */
	@Override
	public void init(int x, int y, int z) throws ComposantError {
		this.x = x;
		this.y = y;
		this.z = z;
	}

	/** _________________________________________________________ OBSERVATORS */
	@Override
	public int x() {
		return x;
	}

	@Override
	public int y() {
		return y;
	}

	@Override
	public int z() {
		return z;
	}
}
